package com.example.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author ding
 * @since 2024/7/15
 */
//开启定时任务
@EnableScheduling
//开启定时任务的异步处理  如果不加，出现异常该定时任务就会直接结束
@EnableAsync
@Component
@Slf4j
public class MyTask {

 @Scheduled(cron = "0/5 * * * * ?")  //每隔五秒执行一次
    public void myTask1() {

    }

}
